package com.tianqu.tms.www.system.controller;

import java.util.ArrayList;
import java.util.List;

import com.tianqu.tms.core.base.Logger;
import com.tianqu.tms.core.base.TmsController;
import com.tianqu.tms.core.base.TxController;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.core.exception.TmsException;
import com.tianqu.tms.core.exception.TransactionException;
import com.tianqu.tms.entity.AucBidType;

/**
 * @author zhangxueliang 竞价模式一览controller
 */
public class AucBidTypeListTopController extends TmsController {

	private Logger logger = Logger.getLogger(AucBidTypeListTopController.class);
	public static final String AUCBIDTYPELIST = "aucBidTypeList";

	@SuppressWarnings("unchecked")
	@Override
	public void execute(UserContext uc) throws Exception {
		logger.debug(this.getClass().getName() + "#execute was called.");
		TxController controller = TxController.getTxController();

		// 添加事务提交异常捕获
		try {
			controller.begin();
			List aucBidTypeList = new ArrayList();
			AucBidType aucBidType = AucBidType.getInstance();
			aucBidTypeList = aucBidType.loadAucBidType();
			uc.setAttribute(AUCBIDTYPELIST, aucBidTypeList);

			logger.debug(this.getClass().getName() + "#execute was completed.");
			controller.commit();
		} catch (Exception e) {
			try {
				controller.rollback();
			} catch (TransactionException e1) {
				throw new TmsException(TmsException.DB_TXCRROR, e1);
			}
			// 系统异常
			if (e instanceof TmsException) {
				throw e;
			}
			throw new TmsException(TmsException.DB_TXCRROR, e);
		}

	}

}
